'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url api/pub/EpisodeList 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		const db = uniCloud.database();
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, _ } = util;
		let { uid, page_index, page_size, timestamp, signature } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		if (!timestamp || timestamp.length != 13) {
			res.code = -1;
			res.msg = "timestamp参数错误,必须为13位时间戳";
			return res;
		}
		
		if (!page_index || page_index < 1 || page_index > 500) {
			res.code = -1;
			res.msg = "page_index参数错误";
			return res;
		}

		if (!page_size || page_size < 1 || page_size > 200) {
			res.code = -1;
			res.msg = "page_size为必填项";
			return res;
		}

		page_index = page_index - 1;

		res.EpisodeList = await db.collection('a_tv').skip(page_index * page_size * 1).limit(page_size * 1)
			.get()



		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
